const detailTpl = require('../views/detailview/renderdetail.html');
import getdata from '../models/getdata'
const  headerTpl = require('../views/detailview/header.html');
const recommendTpl = require('../views/detailview/recommend.html');
class RenderDetail{
    constructor(){
        this.title_one = $('.title1');
        this.title_two = $('.title2');
        this.title_three = $('.title3');
        this.title_one_position = $(this.title_one).position();
        this.title_two_position = $ (this.title_two).position();
        this.title_three_position = $(this.title_three).position();
        $('.nav-detail').on("click",() => {
            console.log(111);
            scrollTo(0,0);
        })
        $('.nav-requierment').on("click",() => {
            console.log(222);
            document.body.scrollTop = 0;
            document.documentElement.scrollTop = 0;
        })
        $('.nav-recommend').on("click",() => {
            console.log(333);
            document.body.scrollTop = 0;
            document.documentElement.scrollTop = 0;
        })
        this.render();
        this.changeHash();
        //this.addToEvent();

    }

    changeHash(){
        let hash = location.hash && location.hash.substr(1);

        switch(hash){
            case "kuajing":this.renderkua();break;
            default:""
        }
    }
    renderkua(){
        $('.detial-top').html(headerTpl);
        $('.sell-content').html(recommendTpl);
        $('.imgfram').css({'background-image' : 'url("https://img.alicdn.com/bao/uploaded/i1/2251059038/O1CN01MWgFJ12GdSC0LvBaP_!!0-item_pic.jpg_400x400")' });
        $('.imgfram').css({'display':'flex','justify-content': 'flex-end'});
        $('.img-desc span').css({'color' : '#fff','font-size' : '.18rem','margin-top':'.2rem'});
    }
    async render(){
        let list = (await getdata.getrecent()).suggest;
        //console.log(list);
        let html = template.render(detailTpl,{
            list
        })
        $('.recommend-list').html(html);
    }
    toAddress(){
        $("window").scroll(function(){
        })
    }



    
}

new RenderDetail();